﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace English_v2
{
    public partial class TutorialForm : Form
    {
        private int page = 0;

        public int Page
        {
            get
            {
                return this.page;
            }
            set
            {
                this.page = value;
            }
        }
        
        public TutorialForm()
        {
            InitializeComponent();
        }

        private void TutorialForm_Load(object sender, EventArgs e)
        {
            this.LoadLabelValue();
            this.actualPageLabel.Text = (page + 1).ToString();
            if (this.page == 2)
            {
                this.nextArrow.Enabled = false;
            }
            else
            {
                if (this.page == 0)
                {
                    this.prevArrow.Enabled = false;
                }    
            }
        }

        private void LoadLabelValue()
        {

            switch (this.page)
            {
                case 1:
                    this.readFile("Files/words_info.txt");
                    break;
                case 2:
                    this.readFile("Files/sentence_info.txt");
                    break;
                default:
                    this.readFile("Files/general_info.txt");
                    break;
            }
        }

        private void readFile(string path)
        {
            try
            {
                this.tutorialText.Text = (string)System.IO.File.ReadAllText(@path);
            }
            catch (Exception e)
            {
                MessageBox.Show("Chyba pri citani suboru s tutorialom!\n[" + e.ToString() + "]");
                this.Close();
            }
        }

        private void closeButton_MouseMove(object sender, MouseEventArgs e)
        {
            this.closeButton.Image = English_v2.Properties.Resources.close_icon_red;
        }

        private void closeButton_MouseLeave(object sender, EventArgs e)
        {
            this.closeButton.Image = English_v2.Properties.Resources.close_icon;
        }

        private void closeButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void nextArrow_MouseMove(object sender, MouseEventArgs e)
        {
            this.nextArrow.Image = English_v2.Properties.Resources.next_arrow_blue;
        }

        private void nextArrow_MouseLeave(object sender, EventArgs e)
        {
            this.nextArrow.Image = English_v2.Properties.Resources.next_arrow;
        }

        private void prevArrow_MouseMove(object sender, MouseEventArgs e)
        {
            this.prevArrow.Image = English_v2.Properties.Resources.prev_arrow_blue;
        }

        private void prevArrow_MouseLeave(object sender, EventArgs e)
        {
            this.prevArrow.Image = English_v2.Properties.Resources.prev_arrow;
        }

        private void nextArrow_Click(object sender, EventArgs e)
        {
            this.page++;
            if (this.page == 2)
            {
                this.nextArrow.Enabled = false;
            }
            this.prevArrow.Enabled = true;
            this.LoadLabelValue();
            this.actualPageLabel.Text = (page + 1).ToString();
        }

        private void prevArrow_Click(object sender, EventArgs e)
        {
            this.page--;
            if (this.page == 0)
            {
                this.prevArrow.Enabled = false;
            }
            this.nextArrow.Enabled = true;
            this.LoadLabelValue();
            this.actualPageLabel.Text = (page + 1).ToString();
        }

    }
}
